<template>
	<view v-if="allLoginShow==true">	
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="pic" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20"><text>{{loginForm.user}}</text></view>
				<view class="u-font-14 u-tips-color">学号:<text>{{loginForm.id}}</text></view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="attach" title="我的信誉分" @click="naviTo('/pages/myinfo/components/creditScore/creditScore')">
		         <u-tag text="100" type="success" size="mini"></u-tag>
				</u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item :arrow="false" icon="chat" title="消息通知" @click="naviTo('/pages/myinfo/components/noticeInfo/noticeInfo')">
				<u-row slot="right-icon">
					<u-badge type="error" :count="noticeLength"  :absolute="true" :offset="[39,70]"></u-badge>
					<u-icon name="arrow-right"></u-icon>
				</u-row>
				
				</u-cell-item>
				<u-cell-item icon="phone" title="联系电话"  :arrow="false">
					<text>{{loginForm.pho}}</text>
				</u-cell-item>
				
				<u-cell-item icon="map" title="学校" :arrow="false"><text>{{loginForm.school}}</text> </u-cell-item>
				<u-cell-item icon="edit-pen" title="信息修改" @click="naviTo('/pages/myinfo/components/editInfo/editInfo?info='+JSON.stringify(loginForm))">
				</u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="heart" title="关于我们" @click="isAboutUsShow=true"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-60">
			<u-button type="error" @click="outLogin">退出登录</u-button>
		</view>
		<u-modal v-model="isAboutUsShow" :title="aboutUs.title" :content='aboutUs.content'></u-modal>
		<u-top-tips ref="uNoticeInfoTips"></u-top-tips>
		
	</view>
	
	
</template>

<script>
	export default {
		data() {
			return {
				allLoginShow:true,
				pic:'/static/otherImg/testImg1.jpg',
				isAboutUsShow: false,
				isTrueSelect:false,
				aboutUs: {
					title:"关于我们",
					content:"欢迎使用这个关于我们的第一代移动端程序"
				},
				noticeLength:0,
				loginForm:{
					user:"",
					school:"",
					id:"",
					school:"",
					pho:"18380827896",
					sumcredit:0
				}
			}
		},
		onLoad(options){
			this.loginForm.id=getApp().globalData.userid
			console.log(this.loginForm.id)
			this.getnews()
		},
		onShow() {
			this.loginForm.id=getApp().globalData.userid
			// console.log(this.loginForm.id)
			// console.log("show")
			// console.log(getApp().globalData.userid)
			this.getnews()
			this.getAllInfoNotice()
			uni.$on("newInfo",res=>{
				this.loginForm = res
				this.$refs.uNoticeInfoTips.show({
					title: `信息修改成功！`,
					type: 'success',
					duration: '2300'
				})
				uni.$off("newInfo")
			})
		},
		methods: {
			naviTo(nextUrl){
				uni.navigateTo({
					url:nextUrl
				})
			},
			async getAllInfoNotice() {
				const  {data:res}= await this.$myRequest({
					url: 'InformationController/queryinformation',
					data:{
						userid:this.loginForm.id
					}
				})
				let temp = res.filter(item=>{
					return item.isTrue==0
				})
				this.noticeLength=temp.length
			},
			async getnews(){
				const {data:res}=await this.$myRequest({
					url:'UserController/userQuery',
					data:{
						userid:getApp().globalData.userid
					},
					method:'POST'
				})
				console.log(res);
				this.loginForm.pho=res.phonenumber
				this.loginForm.user=res.name
				this.loginForm.school=res.school
				this.loginForm.sumcredit=res.sumcredit
			},
			aboutUsBtn(){
				
			},
			async	goLogin(){
				// const {data:res} = await this.$myRequest({
				// 	url:'/alluser'
				// })
				
				for(let key in this.loginForm){
					if(this.loginForm[key]==""){
						return this.$refs.uNoticeInfoTips.show({
					title: `对不起 ,消息没填完整`,
					type: 'error',
					duration: '2300'
				})
					}
				}
				
				
				this.$refs.uNoticeInfoTips.show({
					title: `欢迎${this.loginForm.user}的登录,已经为你查到该学校场地信息`,
					type: 'success',
					duration: '2300'
				})
				this.allLoginShow = true
				console.log(this.loginForm)
			},
			outLogin(){
				this.loginForm = {},
				
				// this.allLoginShow = false
				uni.navigateTo({
					url:'/pages/logins/login'
				})
			},
			confirmSchool(valueArray){
				this.loginForm.school = valueArray[0].label
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.user-box{
	background-color: #fff;
}
.rr{
	display: flex;
	align-items: center;
	justify-content: center;
}
.LoginAera{
	.schoolSeBtn{
		margin-left: 37%;
		margin-top: 2%;
	}
	  .content {
	        background: #83ffed;
	        width: 100vw;
	        height: 100vh;
	    }
	    .avatorWrapper{
	        height: 30vh;
	        width: 100vw;
	        display: flex;
	        justify-content: center;
	        align-items: flex-end;
	    }
	    .avator{
	        width: 200upx;
	        height: 200upx;
	        overflow: hidden;
	    }
	    .avator .img{
	        width: 100%
	    }
	    .form{
	        padding: 0 100upx;
	        margin-top: 80px;
	    }
	    .inputWrapper{
	        width: 100%;
	        height: 80upx;
	        background: white;
	        border-radius: 20px;
	        box-sizing: border-box;
	        padding: 0 20px;
	        margin-top: 25px;
	    }
	    .inputWrapper .input{
	        width: 100%;
	        height: 100%;
	        text-align: center;
	        font-size: 15px;
	    }
	    .loginBtn{
	        width: 100%;
	        height: 80upx;
	        background: #77B307;
	        border-radius: 50upx;
	        margin-top: 50px;
	        display: flex;
	        justify-content: center;
	        align-items: center;
	        
	    }
	    .loginBtn .btnValue{
	        color: white;
	    }
	    .forgotBtn{
	        text-align: center;
	        color: #EAF6F9;
	        font-size: 15px;
	        margin-top: 20px;
	    }
}
</style>
